/*
package com.atguigu.flink0922.chapter05.transform;

import org.apache.flink.streaming.api.collector.selector.OutputSelector;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SplitStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Collections;

*/
/**
 * @Author lizhenchao@atguigu.cn
 * @Date 2021/3/2 15:49
 *//*

public class Flink06_Split {
    public static void main(String[] args) {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(2);
        
        final DataStreamSource<Integer> s1 = env.fromElements(1, 2, 3, 4, 5, 6, 7, 8, 9, 11).setParallelism(1);
        final SplitStream<Integer> splitStream = s1.split(new OutputSelector<Integer>() {
            @Override
            public Iterable<String> select(Integer value) {
                if (value % 2 == 0) {
                    return Collections.singletonList("偶数");
                } else {
                    return Collections.singletonList("奇数");
                }
            }
        });
        
        final DataStream<Integer> s2 = splitStream.select("偶数");
        final DataStream<Integer> s3 = splitStream.select("奇数");
        
        s2.print("偶数");
        s3.print("奇数");
        
        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
*/
